<?php
class ProjectPage extends Page {
	public static $db = array(
        'BeforeTitle'    => 'Varchar(255)',
        'BeforeText'     => 'Text',
        'AfterTitle'    => 'Varchar(255)',
        'AfterText'     => 'Text',        
	);
	
	public static $has_one = array(
        'BeforeImage'    => 'Image',
        'AfterImage'    => 'Image',
	);
	
	public static $has_many = array(
		'Projects'		=> 'Project',
	);
	
	function getCMSFields(){
		$fields = parent::getCMSFields();
		
		$fields->addFieldToTab('Root.Content.Main', new TextField('BeforeTitle', 'Before title'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextareaField('BeforeText', 'Before text'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new ImageField('BeforeImage', 'Before image (Recommended size: 236 x 112)'), 'Content');
        
		$fields->addFieldToTab('Root.Content.Main', new TextField('AfterTitle', 'After title'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextareaField('AfterText', 'After text'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new ImageField('AfterImage', 'After image (Recommended size: 236 x 112)'), 'Content');
        
		
		$projects = new DataObjectManager(
            $this,
            'Projects',
            'Project',            
             array(
                'Name'				=> 'Project name',
				'delegateThumbnail'	=> 'Image'
             ),
            'getCMSFields_forPopup'
        );
        $projects->setAddTitle('Project');      
        $fields->addFieldToTab('Root.Content.Projects', $projects); 
		
		return $fields;
	}
}

class ProjectPage_Controller extends Page_Controller {	
	public function init() {        
		parent::init();		
	}
}